using Quartz;
using Microsoft.Extensions.Logging;
using RobotClient.Controllers;
namespace RobotClient.Services
{
    public class DoJob : IJob
    {
        private readonly RobotJobControl _jobControl;
        private readonly ILogger<DoJob> _logger;

        public DoJob(RobotJobControl jobControl, ILogger<DoJob> logger)
        {
            _jobControl = jobControl;
            _logger = logger;
        }

        public async Task Execute(IJobExecutionContext context)
        {
            var jobData = context.JobDetail.JobDataMap;
            var jobId = jobData.GetString("jobId");

            _logger.LogInformation("开始执行定时任务 JobID: {JobId}", jobId);
            _logger.LogInformation("从数据库配置获取定时任务参数，正在启动JobID: {JobId}", jobId);
            _jobControl.StartJob(jobId);
        }
    }
}